class F1:
    pass

class s1(F1):
    def show(self):
        print("s1.show")

class s2(F1):
    def show(self):
        print("s2.show")

def Func(obj):
    '''func函数需要接收一个F1类型或者F1子类的类型'''
    obj.show()

s1_obj=s1()
Func(s1_obj) #在Func函数传入S1类的对象

s2_obj=s2()
Func(s2_obj)

#多态：给相同的方法传递不同的类型参数，会有不同的执行效果



#方法多态
class calculator:
    def count(self,args):
        return 1

calc=calculator()

#自定义类型
from random import  choice
#obj是随机返回的类型不确定
obj=choice(['hello woaarld',["a",1,2,3],calc])
print(obj)
print(type(obj))
print(obj.count('a'))







class Duck(object):
    def quack(self):
        print("Quaaaaaaack")
    def feathers(self):
        print("the duck has white and gray feathers.")

class Person(object):
    def quack(self):
        print("the person imitates a duck.")
    def feathers(self):
        print("the person takes a feather from the ground and shows it.")

def in_the_forest(duck):
    duck.quack()
    duck.feathers()

def game():
    donald=Duck()
    john=Person()
    in_the_forest(donald)
    in_the_forest(john)
game()
#多态：不同的对象--》通过函数、执行相同的执行代码---》不同的执行结果